//
//  EmoticonViewMode.swift
//  01-表情键盘 Emotion
//
//  Created by wulei on 15/12/15.
//  Copyright © 2015年 wulei. All rights reserved.
//

import Foundation
class EmoticonManager {
    // 单例
    static let sharedManager = EmoticonManager()
    
    /// 表情包数组
    lazy var packages = [EmotionPackage]()
    
    init() {
        // 添加最近数组
        packages.append(EmotionPackage(dict: ["group_name_cn":"最近A"]))
    
       let path =  NSBundle.mainBundle().pathForResource("emoticons.plist", ofType: nil,inDirectory: "Emoticons.bundle")!
        let dict = NSDictionary(contentsOfFile: path) as! [String: AnyObject]
        
       let array =  (dict["packages"] as! NSArray).valueForKey("id")
        
        for id in array as! [String]{
            loadInfoPlist(id)
        }
      
        
        
    }
    
    private func loadInfoPlist(id: String) {
     
        let path = NSBundle.mainBundle().pathForResource("info.plist",ofType: nil,inDirectory: "Emoticons.bundle/\(id)")!
        
        let dict = NSDictionary(contentsOfFile: path) as! [String: AnyObject]
        packages.append(EmotionPackage(dict:dict))
        
        
    }
    
    
}